package com.taikang.hmp.hbusiness.diabetes.measure.pressure.action.intface;

import java.util.List;

import org.slf4j.Logger;
import org.slf4j.LoggerFactory;

import com.taikang.hmp.frame.common.TKException;
import com.taikang.hmp.frame.common.datastructre.Dto;
import com.taikang.hmp.frame.common.datastructre.support.BaseDto;
import com.taikang.hmp.frame.common.datastructre.support.ResponseDto;
import com.taikang.hmp.frame.common.web.action.BaseAction;
import com.taikang.hmp.hbusiness.diabetes.measure.pressure.service.IPressureService;

/** 
 * 血压
 * author:qrp
 * time:2015年8月5日 上午11:02:42
 */
public class PressureAction extends BaseAction{
	private static Logger logger = LoggerFactory.getLogger(PressureAction.class);

	
	private IPressureService pressureService;

	public IPressureService getPressureService() {
		return pressureService;
	}

	public void setPressureService(IPressureService pressureService) {
		this.pressureService = pressureService;
	}

	public String executeAction() {
		if ("savePressure".equals(requestDto.getMethod())) {
			logger.info("--保存血压测量值 delHemoglobin method --");
			return savePressure();
		} else if ("getPressureList".equals(requestDto.getMethod())) {
			logger.info("--获取血压测量值列表 delHemoglobin method --");
			return getPressureList();
		} else if ("delPressure".equals(requestDto.getMethod())) {
			logger.info("--删除血压测量值 delHemoglobin method --");
			return delPressure();
		} else {
			logger.info("--executeAction 没有 --【" + requestDto.getMethod() + "】方法！");
			throw new TKException("no support method:" + requestDto.getMethod());
		}
	}

	/**
	 * 保存血压测量值
	 * 
	 * @return
	 */
	public String savePressure() {
		logger.info("进入savePressure方法:"+requestDto.toString());
		ResponseDto responseDto = new ResponseDto();
					
		//获取参数
		Dto paramDto = requestDto.getRequestlist().get(0);
		//寻找session
		paramDto = super.appendRequestBase(paramDto, requestDto);
		String result = pressureService.savePressure(paramDto);
		Dto resultDto = new BaseDto();
		resultDto.put("result", result);
		responseDto.pushResultDto(resultDto);
	    //
		super.setDataMap(responseDto);
		logger.info("savePressure方法成功返回:"+responseDto.toString());
		return SUCCESS;
	}
	/**
	 * 删除血压测量值
	 * @return
	 */
	public String delPressure(){
		ResponseDto responseDto = new ResponseDto();
		//获取参数
		Dto paramDto = requestDto.getRequestlist().get(0);
		paramDto = super.appendRequestBase(paramDto, requestDto);
		Dto resultDto = new BaseDto();
		String result = pressureService.delPressure(paramDto);
		resultDto.put("result", result);
		responseDto.pushResultDto(resultDto);
		//
		super.setDataMap(responseDto);
		return SUCCESS;
	}

	/**
	 * 获取血压测量值列表
	 * 
	 * @return
	 */
	public String getPressureList() {
		logger.info("进入getPressureList方法:"+requestDto.toString());
		ResponseDto responseDto = new ResponseDto();			
		//获取参数
		Dto paramDto = requestDto.getRequestlist().get(0);
		//寻找session
		paramDto = super.appendRequestBase(paramDto, requestDto);
		List<Dto> resultList = pressureService.getPressureList(paramDto);
		Dto resultDto = new BaseDto();
		resultDto.put("resultlist", resultList);
		responseDto.pushResultDto(resultDto);
		//
		super.setDataMap(responseDto);
		logger.info("getPressureList方法成功返回结果:"+responseDto.toString());
		return SUCCESS;
	}

}
